import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const router = new VueRouter({
    routes:[
        // {
        //     name:'main',
        //     path:'/',
        //     component:()=>import ('../view/front/main.vue')
        // },
        {
            name:'buy',
            path:'/buy',
            component:()=>import('../view/front/buy.vue')
        },
        {
            name:'login',
            path:'/login',
            component:()=>import ('../view/front/login.vue')
        },
        {
            name:'home',
            path:'/',
            component:()=>import ('../view/front/home.vue')
        },
        {
            name:'flower',
            path:'/flower',
            component:()=>import('../view/front/flower.vue')
        },
        {
            name:'infomation',
            path:'/infomation',
            component:()=>import('../view/front/infomation.vue')
        },
        {
            name:'address',
            path:'/address',
            component:()=>import('../view/front/address.vue')
        },
        {
            name:'order',
            path:'/order',
            component:()=>import('../view/front/order.vue')
        },
        {
            name:'star',
            path:'/star',
            component:()=>import('../view/front/star.vue')
        },
        {
            name:'shopping',
            path:'/shopping',
            component:()=>import('../view/front/shopping.vue')
        },
        {
            name:'person',
            path:'/person',
            component:()=>import('../view/front/person.vue')
        },
        {
            name:'password',
            path:'/password',
            component:()=>import('../view/front/password.vue')
        },
        {
            name:'flowerDetail',
            path:'/flowerDetail',
            component:()=>import('../view/front/flowerDetail.vue')
        },
        {
            path: 'txt1',
            name: 'txt1',
            component: () => import('../view/front/txt/txt1.vue')
          },
          {
            path: 'txt2',
            name: 'txt2',
            component: () => import('../view/front/txt/txt2.vue')
          },
          {
            path: 'txt3',
            name: 'txt3',
            component: () => import('../view/front/txt/txt3.vue')
          },
          {
            path: 'txt4',
            name: 'txt4',
            component: () => import('../view/front/txt/txt4.vue')
          },
          {
            path: 'txt5',
            name: 'txt5',
            component: () => import('../view/front/txt/txt5.vue')
          },
          {
            path: 'txt6',
            name: 'txt6',
            component: () => import('../view/front/txt/txt6.vue')
          },
          {
            path: 'txt7',
            name: 'txt7',
            component: () => import('../view/front/txt/txt7.vue')
          },
          {
            path: 'txt8',
            name: 'txt8',
            component: () => import('../view/front/txt/txt8.vue')
          },
          {
            path: 'txt9',
            name: 'txt9',
            component: () => import('../view/front/txt/txt9.vue')
          },
          {
            path: 'txt10',
            name: 'txt10',
            component: () => import('../view/front/txt/txt10.vue')
          },
          {
            path: 'txt11',
            name: 'txt11',
            component: () => import('../view/front/txt/txt11.vue')
          },
          {
            path: 'txt12',
            name: 'txt12',
            component: () => import('../view/front/txt/txt12.vue')
          },
        
        {
            name:'admin',
            path:'/admin',
            component:()=>import('../view/admin/admin.vue'),
            children:[
                {
                    name:'home',
                    path:'home',
                    component:()=>import('../view/admin/home.vue'),
                },
                {
                    name:'type',
                    path:'type',
                    component:()=>import('../view/admin/type.vue'),
                },
                {
                    name:'list',
                    path:'list',
                    component:()=>import('../view/admin/List.vue'),
                },
                {
                    name:'orders',
                    path:'orders',
                    component:()=>import('../view/admin/orders.vue'),
                },{
                    name:'vip',
                    path:'vip',
                    component:()=>import('../view/admin/vip.vue'),
                }
            ]
        },

        // 后台的路径

    ]
})


// 全局前置守卫，初始化时执行，每次路由切换前执行
// router.beforeEach((to, from, next) => {

//   // 判断当前路由是否需要进行权限控制
// //   if (!localStorage.getItem("user")) {
// //     this.$router.push("/login")
// //   } else {
// //        // 其他的情况都放行
// //           next()
// //     }


// })


// //全局后置守卫，初始化时执行，每次路由切换前执行
// router.afterEach((to, from) => {

//   // 判断当前路由是否需要进行权限控制
//   if (to.meta.title) {
//     document.title = to.meta.title  //修改网页的title
//   } else {
//        document.title = 'vue'   
//     }


// })


// 注意：：：meta是Vue专门提供给程序员写自己想写的东西的。

export default router